import 'dart:convert';

Client clientFromJson(String str) {
  final jsonData = json.decode(str);
  return Client.fromMap(jsonData);
}

String clientToJson(Client data) {
  final dyn = data.toMap();
  return json.encode(dyn);
}

class Client {
  int id=0;
  String text="";
  bool completed=false;

  Client(int id,String text,bool completed)
  {
    this.id=id;
    this.text=text;
    this.completed=completed;
  }

  factory Client.fromMap(Map<String, dynamic> json) => new Client(
        json["id"],
        json["text"],
        json["completed"]==1?true:false
      );

  Map<String, dynamic> toMap() => {
        "id": id,
        "text": text,
        "completed": completed?1:0,
      };
}
